//
//  YXScreenView.swift
//  SortProject
//
//  Created by ALH000355 on 2021/9/8.
//
//https://www.jianshu.com/p/6b5df3be02ca
import UIKit
let SCREEN_WIDTH = UIScreen.main.bounds.size.width
let SCREENH_HEIGHT = UIScreen.main.bounds.size.height
let collectionWidth = 100

class YXScreenView: UIView {
    
    func uiConfig() {
        self.backgroundColor = .white
        self.addSubview(self.collection)
    }
    func dataConfig() -> Void {
        let model1: YXscreenClassModel = YXscreenClassModel.init()
        model1.name = "宝骏"
        screenOneSectionlList.append(model1)
        
        let model2: YXscreenClassModel = YXscreenClassModel.init()
        model2.name = "宝马"
        screenOneSectionlList.append(model2)
        
        let model3: YXscreenClassModel = YXscreenClassModel.init()
        model3.name = "保时捷"
        screenOneSectionlList.append(model3)
        
        let model4: YXscreenClassModel = YXscreenClassModel.init()
        model4.name = "奔驰"
        screenOneSectionlList.append(model4)
        
        let model5: YXscreenClassModel = YXscreenClassModel.init()
        model5.name = "奥迪"
        screenOneSectionlList.append(model5)
        
        let model6: YXscreenClassModel = YXscreenClassModel.init()
        model6.name = "宝骏"
        screenOneSectionlList.append(model6)
        
        let model7: YXscreenClassModel = YXscreenClassModel.init()
        model7.name = "宝马"
        screenOneSectionlList.append(model7)
        
        let model8: YXscreenClassModel = YXscreenClassModel.init()
        model8.name = "保时捷"
        screenOneSectionlList.append(model8)
        
        let model9: YXscreenClassModel = YXscreenClassModel.init()
        model9.name = "奔驰"
        screenOneSectionlList.append(model9)
        
        let model10: YXscreenClassModel = YXscreenClassModel.init()
        model10.name = "奥迪"
        screenOneSectionlList.append(model10)
        
        let model21: YXscreenClassModel = YXscreenClassModel.init()
        model21.name = "知乎"
        screenTwoSectionlList.append(model21)
        
        let model22: YXscreenClassModel = YXscreenClassModel.init()
        model22.name = "腾讯视频"
        screenTwoSectionlList.append(model22)
        
        let model23: YXscreenClassModel = YXscreenClassModel.init()
        model23.name = "优酷"
        screenTwoSectionlList.append(model23)
        
        let model24: YXscreenClassModel = YXscreenClassModel.init()
        model24.name = "爱奇艺"
        screenTwoSectionlList.append(model24)
        
        let model25: YXscreenClassModel = YXscreenClassModel.init()
        model25.name = "哔哩哔哩"
        screenTwoSectionlList.append(model25)
        
        collection.reloadData()
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        uiConfig()
        dataConfig()
    }
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    public lazy var collection: UICollectionView = {
        let layout = UICollectionViewFlowLayout.init()
        layout.minimumLineSpacing = 12
        layout.sectionInset = UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5)
        let collection = UICollectionView.init(frame: CGRect.init(x: 15, y: 15, width: SCREEN_WIDTH - 90, height: SCREENH_HEIGHT - 30), collectionViewLayout: layout)
        collection.backgroundColor = .white
        collection.delegate = self
        collection.dataSource = self
        collection.alwaysBounceVertical = true
        collection.showsVerticalScrollIndicator = true
        collection.register(YXScreenCell.self, forCellWithReuseIdentifier: "SwiftCollectionViewCell")
        collection.register(UICollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "SwiftHeaderCollectionReusableView")
        collection.register(YXCollectionFooterView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: "YXCollectionFooterView")
        return collection
    }()

   
    //第一组section里的几个数据
    var screenOneSectionlList = [YXscreenClassModel]()
    //第三组section数组模型
    var screenTwoSectionlList = [YXscreenClassModel]()

    
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {

    }
}
